<template>
	<view>
		<text>{{mess}}</text>
		<view>
			<text>密码</text>
			<input v-model="user.password" password />
		</view>
		<view>
			<text>确认密码</text>
			<input v-model="user.password2" password/>
		</view>
		<button @click="changepwd">确认修改</button>
	</view>
</template>

<script>
	import common from '../../common/common.js';
	export default {
		data() {
			return {
				user:{
					password: '',
					password2: ''
				},
				mess: ''
			}
		},
		methods: {
			changepwd(){
				if(this.user.password != this.user.password2){
					this.mess = '两次密码不一样';
					return;
				}
				var userID=this.userID.id
				
				this.myReq({
					url: 'change_pwd',
					method: "POST",
					data: JSON.stringify({'password':this.user.password})
				}).then((res)=>{
					if(res.data){
						this.mess='修改密码成功！';
						uni.setStorageSync('userID', res.data.userID);
						this.userID.id = res.data.userID
						uni.switchTab({
							url:"../my/my"
						})
					}else{
						this.mess='修改失败！'
					}
				})
			}
		}
	}
</script>

<style>
input{
		background-color: #F8F8F8;
		font-size: 60rpx;
		border:2rpx solid;
		border-radius: 25rpx;
	}
</style>
